<?php

/**
 * MembershipFee Service class for communicating between controllers and
 * persistent storage
 */
class Core_Service_MembershipFee extends RedCross_Service_ServiceAbstract
{
    /**
     * Constructor
     * @param Core_Gateway_MembershipFee $gateway
     */
    public function __construct(Core_Gateway_MembershipFee $gateway) {
        parent::__construct($gateway, 'Core_Model_MembershipFee');
    }

    public function create($year, $memberId) {
        $fee = new Core_Model_MembershipFee();
        $fee->member_id = $memberId;
        $fee->year = $year;
        return $fee->save() !== false;
    }

    public function fetchYears() {
        return $this->getGateway()->fetchYears();
    }

    public function fetchByMemberIdAndYear($memberId, $year) {
        return $this->getGateway()->fetchByMemberIdAndYear($memberId, $year);
    }

    public function fetchPaidMembersForYear($year) {
        return $this->getGateway()->fetchPaidMembersForYear($year);
    }
}

?>
